<?php
/**
 * Pipahr
 *
 * @author mawei
 * @copyright 2013 pipahr.com
 */
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if (isDevMode()) {
   OCP\Util::addStyle('interview', 'interview');
   OCP\Util::addScript('interview', 'persontest');
} else {
   OCP\Util::addStyle('static', 'interview');
   OCP\Util::addScript('static', 'apps/interview.persontest.min');
}

$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");
$app=PFactory::getApplication();
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('interview/js', 'interview.php'));?>"></script>
<?php if($_['test_flag']):?>
<div class="lgrg_form test_errorbox">
   <div class="hr_inputinfo">
      <div class="hr_testerinfo_input">
         <div class="test_sub_des">
            <div class="test_sub_success"><img src="/images/3/submit_error.png"/></div>
            <div class="test_notice">您正在测试中，请继续完成测试！</div>
         </div>
      </div>
   </div>
</div>
<?php else:?>
<div class="container sticky_element" style="margin-top:-20px;">
   <div class="row-fluid">
      <div class="span12">
         <div class="company_qes_fixed clearfix">
         <?php if(empty($_['sheetid'])): ?>
            <? echo $_['persontestInfo']->comp_name ? $_['persontestInfo']->comp_name : ''?>-性格评测
         <?php else: ?>
                              性格评测
         <?php endif; ?>
         </div>
      </div>
   </div>
</div>

<div class="row-fluid hr_oneconn_margin">
   <div class="span12 oneconn_box">
      <div class="personsheet">
         <dl>
            <dt class="yahei"><?=$_['persontestInfo']->sheettitle?></dt>
            <dd>
            <div style="float: left;" id="persontest_info">
               <?php
               /* not used for now
               switch ($_['persontestInfo']->sheetalias) {
                  case 'ENNEAGRAM':
                     echo '下面是九型人格测试量表，请做出与自己对应的选择。';
                     break;
                  case 'MBTI':
                     echo '本测试题目没有对错之分，请根据自己的实际情况选择。';
                     break;
                  case 'HOLLAND':
                     echo '请根据对每一题目的第一印象作答，不必仔细推敲，答案没有好坏、对错之分。';
                     break;
                  default:
                     echo '请选择符合您的答案，但要尽可能少选中性答案。';
                     break;
               }
               */
               echo $_['persontestInfo']->topwords . '推荐用时：' . $_['persontestInfo']->totaltime . '分钟。';
               ?></div><div style="margin-left:760px" class="person_test_timetip" id="timeleft"></div>
            </dd>
         </dl>
         <div class="persontestprogress clearfix">
            <div class="progress pull-left">
               <div class="bar" style="width:0%;"></div>
            </div>
            <div class="totalnum pull-left medium"><span class="qnum_done">0</span>/<?=$_['persontestInfo']->qcount?>题</div>
         </div>
      </div>
      <div class="lgrg_form">
         <form action="<?php echo OC_Helper::linkToRoute("persontest_save");?>" method="post" name="persontestform" id="persontestform">
         <div id="persontest_container" class="persontest_container <?=($_['persontestInfo']->layout == 'vertical') ? 'vertical' : '';?>">
            <div id="#persontest_page1" class="persontest_page">
         <?php
         $page = 1;
         $qcount = $_['persontestInfo']->qcount;
         foreach ($_['persontestQuestions'] as $k => $v):
            if (!is_int($k))
               continue;
            $op_label = array('A','B','C','D','E','F','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
         ?>
            <?php
            if ($k != 0 && ($k%5) == 0) {
               $page = ceil(($k+1)/5);
            ?>
            </div>
            <div id="persontest_page<?=$page?>" class="persontest_page hide">
            <?php
            }
            ?>
               <div class="test_questionbox persontest_questionbox">
                  <h6><?=$k+1?>. <?=$v->question;?><span class="error_container"></span></h6>
                  <div class="test_question_select normal clearfix">
                     <?php foreach ($v->answer as $key => $choice):?>
                     <label class="radio pull-left">
                        <input type="radio" class="{required:true, messages:{required:'请选择答案'}}" name="panswers[<?=$v->id?>]" value="<?=$key?>"/>
                        <?=$op_label[$key]?>. <?php echo htmlspecialchars($choice->choice);?>
                     </label>
                     <?php endforeach;?>
                  </div>
               </div>
         <?php endforeach;?>
            </div>
         </div>

         <div class="ready_btn ready_btn_top">
            <input class="ppp_bluebtn ready_btn_width" id="nextSubmit" style="margin:auto;<?=($qcount > 5 ? '' : 'display: none;')?>" type="submit" value="提交并进入下一页"/>
            <input class="ppp_bluebtn ready_btn_width" id="personTestSubmit" style="margin:auto;<?=($qcount > 5 ? 'display: none;' : '')?>" type="submit" value="完成并提交"/>
            <?php if(empty($_['sheetid'])): ?>
            <input type="hidden" id="jobid" name="jobid" value="<?=$_['persontestInfo']->jobid?>"/>
            <?php else: ?>
            <input type="hidden" id="typefrom" name="typefrom" value="joobseeker"/>
            <?php endif; ?>
            <input type="hidden" id="qcount" name="qcount" value="<?=$_['persontestInfo']->qcount?>"/>
            <input type="hidden" id="pagecount" name="pagecount" value="<?=$_['persontestInfo']->pagecount?>"/>
            <input type="hidden" name="sheetid" id="sheetid" value="<?=$_['persontestInfo']->sheetid?>"/>
            <input type="hidden" name="sheetalias" value="<?=$_['persontestInfo']->sheetalias?>"/>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <?php if($app->getUserState('persontest_start_time_'.$_['persontestInfo']->sheetid)!=null):?>
            <input type="hidden" id="winid_persontest" name="winid_persontest" value="<?php echo $app->getUserState('persontest_start_time_'.$_['persontestInfo']->sheetid); ?>">
            <?php endif;?>
            <input type="hidden" id="persontest_totaltime" value="<?php echo $_['persontestInfo']->totaltime;?>"/>
            <div id='errormsg' class='error' style='margin-top: 10px; display:none; text-align:center;'></div>
         </div>
         </form>
      </div>
   </div>
</div>
<?php endif;?>